package com.ly.count.utils;

import com.ly.count.context.CPlusLoginContext;
import com.ly.count.holder.TokenHolder;
import org.apache.commons.lang3.StringUtils;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public class LoginContextUtil {

    public  static Map<String, CPlusLoginContext> contextMap = new ConcurrentHashMap<>(100);
    public static void put(String token , CPlusLoginContext cPlusLoginContext) {
        if(StringUtils.isEmpty(token)){
            contextMap.put( TokenHolder.getToken(),cPlusLoginContext);
        }else {
            contextMap.put( token,cPlusLoginContext);
        }

    }

    public static CPlusLoginContext getLoginContext() {
        return contextMap.get(TokenHolder.getToken());
    }

}
